package com.homework.homework4;

import java.util.Arrays;

public class Test04 {
    public static void main(String[] args) {
        String[] arr={"1","3","2","4","5","7",};
        String[] swap2 = swap(1, 5, arr);
        for (String s : swap2) {
            System.out.print(s+" ");
        }
        System.out.println("");
        Integer[] arr1={1,2,3,4,5,6,7};
        Integer[] swap1 = swap(1, 3, arr1);
        for (Integer integer : swap1) {
            System.out.print(integer+" ");
        }
    }

    private static <E> E[] swap(int i,int j,E[] arr) {
            E temp=arr[i];
            arr[i]=arr[j];
            arr[j]=temp;
            return arr;
    }
}
